package com.jilintongyi.jlcrtvu.entity;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ManyToMany;

import org.hibernate.annotations.Table;
import org.hibernate.annotations.Where;
import org.springframework.security.core.GrantedAuthority;

import com.fasterxml.jackson.annotation.JsonIgnore;

@Entity
@Table(appliesTo = "sys_authority", comment = "系统权限表")
public class SysAuthority extends BaseEntity implements GrantedAuthority {
	@ManyToMany(mappedBy = "authorities", fetch = FetchType.LAZY)
	@Where(clause = "deleted=false")
	@JsonIgnore
	private List<SysRole> roles;

	@Column(nullable = false, columnDefinition = "varchar(255) comment '权限名称'")
	private String authorityName;

	@Column(nullable = false, columnDefinition = "varchar(255) comment '权限'")
	private String authority;

	@Override
	public String getAuthority() {
		return authority;
	}

	public List<SysRole> getRoles() {
		return roles;
	}

	public void setRoles(List<SysRole> roles) {
		this.roles = roles;
	}

	public String getAuthorityName() {
		return authorityName;
	}

	public void setAuthorityName(String authorityName) {
		this.authorityName = authorityName;
	}

	public void setAuthority(String authority) {
		this.authority = authority;
	}
}
